How to Migrate a GitLab Project from current instance to Cloud Clusters
In this article, we will show you how to migrate one project from your current giltab instance to Cloud Clusters' GitLab instance. As an example, we will migrate a gitlab project named “nodejs”.
1 Create a new group and a new empty project in the destination gitlab instance
First, make sure you have created a GitLab instance on the Cloud Clusters platform. Then, you need to create a new group and a new empty project in the destination GitLab instance. The name of the group/project can be the same as or different from the original one. Here, we recommend setting up a same group/project name.
2 Add the SSH Key to both of Gitlab instances
Usually, you need to clone your project to your local laptop/remote server. Before cloning your project, you need to add your SSH key to both of your gitlab instances. You can find the SSH Key at ~/.ssh/id_rsa.pub on your local laptop/remote server. If there have no file named id_rsa.pub, you can generate an SSH Key by the command below, and press “Enter” while you are required to enter some information. If id_rsa.pub exsits. You can skip to generate SSH Key.
# ssh-keygen -t rsa -C youremail@example.com
Once the generation process finishes, you can check the SSH Key:
# cat ~/.ssh/id_rsa.pub
Copy the SSH Key and add it to both Gitlab instances on the User Settings > SSH Key page.
3 Git clone the Source Project
Git clone the source project to your local laptop/remote server using the command below:
# git clone --bare <gitlab-project-original-url>
Note: The GitLab project URL must contains the custom port.
4 Disable Protected branches for the destination gitlab project
- Log in to your GitLab Account
- Select Repository
- Click the Settings menu
- Click the Repository menu
- Click Protected Branches
- Click Allow to force push
- Click Unprotected
5 Push to the Destination Gitlab Project
# cd nodejs.git
# git push --mirror --force <gitlab-project-original-url>
If you get an error like the following screenshot, please refer to the step 4 on how to disable protected branches for the destination gitlab project.
6 Migrate multiple gitlab projects
You can repeat the steps above to migrate more giltab projects. If you need any further assistance, feel free to contact our support.